import { BaseController } from '../../../lib/base/controller';
import routerDecorator from '../../../lib/router';
import { Context } from 'egg';

/**
 * 系统-用户
 */
@routerDecorator.prefix('/admin/sys/user', [ 'add', 'delete', 'update', 'info', 'list', 'page' ])
export default class SysUserController extends BaseController {
    constructor (ctx: Context) {
        super(ctx);
        this.setEntity(this.ctx.repo.sys.User);
        this.setService(this.service.sys.user);
    }

    /**
     * 新增
     */
    @routerDecorator.post('/add')
    protected async add () {
        await this.service.sys.user.add(this.ctx.request.body);
        this.res();
    }
}
